package top.lt.lt_ssm.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.lt.lt_ssm.bean.message;
import top.lt.lt_ssm.service.MessageService;
import top.lt.lt_ssm.util.SimpleResult;
/*								message				*/
@Controller
@RequestMapping("/msg")
public class MsgController {
	@Resource
	private MessageService messageService;
	
	@RequestMapping("/Getin1/{in1}")
	public @ResponseBody SimpleResult Getin1(@PathVariable("in1") int id) {
		List<message> gatin1 = messageService.gatin1(id);
		return new SimpleResult(gatin1);
	}
	@RequestMapping("/Getin2/{in2}")
	public @ResponseBody SimpleResult Getin2(@PathVariable("in2") String usn) {
		List<message> gatin2 = messageService.gatin2(usn);
		gatin2.forEach(s->{
			System.out.println(s);
		});
		return new SimpleResult(gatin2);
	}
	@RequestMapping("/Getin3/{in3}")
	public @ResponseBody SimpleResult Getin3(@PathVariable("in3") String bt) {
		List<message> gatin3 = messageService.gatin3(bt);
		gatin3.forEach(s->{
			System.out.println(s);
		});
		return new SimpleResult(gatin3);
	}
	
	@RequestMapping("/del/{messId}")
	public @ResponseBody SimpleResult del(@PathVariable("messId") int messId){
		int delByid = messageService.DelByid(messId);
		return new SimpleResult(delByid>0?true:false);
	}
	
	@RequestMapping("/GetAll")
	public @ResponseBody SimpleResult GetAll() {
		List<message> gma = messageService.gatall();
		gma.forEach(s->{
			System.out.println(s);
		});
		return new SimpleResult(gma);
	}
	
	@RequestMapping("/list")
	public String msgList() {
		return "message/msg_list";
	}
	
	
}
